[ckeditor] apply font size using execCommand

Posted by Wiika on Stack Overflow See other posts from Stack Overflow or by Wiika
Published on 2010-05-04T17:26:30Z Indexed on 2010/05/04 17:28 UTC
Read the original article Hit count: 1151

Filed under:
|

Hi all,

var wgetFrame = window.frames[0]
wframeDoc = wgetFrame.document;

editor.focus();
editor.execCommand('bold');
wframeDoc.execCommand('forecolor',false,'#00ff00');
wframeDoc.execCommand('JustifyCenter', false, null);
wframeDoc.execCommand('fontsize', false, 15);

(i use the code above as a plugin in CKEditor)

bold, forecolor and JustifyCenter , they all rend corectly , the selected text is wrapped by a span element

but when applying the fontsize command , the selected goes inside the font element, i know this is correct, but it need it to be inside a span element

i need to know why bold, forecolor and JustifyCenter are wrapped by span and fontsize not !!

and also if there another way to apply this styles

( ps : i run those commands when ckeditor is initialized, even if the editort doesn't contain any text, when u write the style definied is applied )


CKEDITOR.editorConfig = function(config) {
CKEDITOR.addStylesSet('customStyles',
[
    { name: 'Header 1', element: 'h1' },
    { name: 'Header 2', element: 'h2' },
    { name: 'Header 3', element: 'h3' },
    { name: 'Text', element: 'p' },
    { name: 'Left Align', element: 'img', attributes: { 'class': 'ImageLeft'} },
    { name: 'Right Align', element: 'img', attributes: { 'class': 'ImageRight'} }
]);

};

can i apply editor.execCommand( "Header 1" ); ??

© Stack Overflow or respective owner

Related posts about ckeditor

Related posts about font